package umn.monopolybankservice

class Game {

    String name
    double startMoney
    static hasMany = [players: Player]

    static constraints = {
        name blank: false
        startMoney validator: {return it>=0;}
    }

    def getJsonString = {
        String playerStr = ""
        players.each {
            playerStr += it.getJsonString() + ","
        }
        playerStr = playerStr.substring(0, playerStr.length()-1)
        return '{"id":"' + this.id + '","name":"' + this.name + '","startMoney":"' + this.startMoney + '","players":[' + playerStr + ']}'
    }
}
